package wodegua.d24_file_io;

import java.io.*;
import java.util.Arrays;

/**
 * 目标:使用字节流完成对文件的复制操作
 */
public class d9_CopyTest {
    public static void main(String[] args) throws Exception {
        //将文件（D:\My Documents\Desktop\Dingtalk_20240205115523.jpg）复制到文件夹（E:\data）下

        String inSrc = "D:\\My Documents\\Desktop\\Dingtalk_20240205115523.jpg";
        String outSrc = "E:/data/Dingtalk_20240205115523.jpg";

//        InputStream is = new FileInputStream(inSrc);
//        OutputStream os = new FileOutputStream(outSrc);
        InputStream is = new FileInputStream("E:\\data\\0b59400dd28a84adec3b39def39d0bd4.dat");
        OutputStream os = new FileOutputStream("E:\\data\\0b59400dd28a84adec3b39def39d0bd4.txt");

//        byte[] bis = Files.readAllBytes(Paths.get(inSrc));
//        os.write(bis);

        byte[] bis = new byte[1024];
        int len;
        while ((len = is.read(bis)) != -1) {
            System.out.print(Arrays.toString(bis));
//            os.write(bis,0,len);
        }

        is.close();
        os.close();
    }
}
